package com.tree;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhong
 * @version 1
 * @date 2022/04/16
 * @contact 1478168700@qq.com
 **/
public class BreakPointDemo {
    /**
     * 行断点
     *
     * @return : void
     * @author : zrs
     * @date : 2022-04-16 14:59
     */
    public static void lineBreakPoint() {
        System.out.println("lineBreakPoint");
    }

    public static void detailBreakPoint() {
        System.out.println("详细断点");
    }

    /**
     * 异常断点 | 全局挂起
     */
    public static void exception() {
        Object obj = null;
        obj.toString();
    }


    /**
     * 字段断点 | 数据读写监控
     */
    public static void field() {
        Person person = new Person();
        person.setName("name");
        String name = person.getName();
        System.out.println(name);

    }

    /**
     * 强制返回 | 避免操作资源
     */
    public static void forceReturn() {
        System.out.println("bug");
        System.out.println("定位到bug啦");

        System.out.println("db操作");
        System.out.println("redis操作");
        System.out.println("mq操作");
    }

    /**
     * 条件
     */
    public static void condition() {
        for (int i = 0; i < 100; i++) {
            System.out.println(i);
            if (i == 50) {
                System.out.println("condition");
            }
        }
    }

    public static void multipleThread(){
        Runnable runnable = ()->{
            System.out.println(Thread.currentThread().getName());
        };

        Thread t1 = new Thread(runnable,"t1");
        Thread t2 = new Thread(runnable,"t2");
        Thread t3 = new Thread(runnable,"t3");

        t1.start();
        t2.start();
        t3.start();
    }

    public static void stream(){
        List<Integer> ids = new ArrayList<>();
        ids.add(1);
        ids.add(2);
        ids.add(3);
        ids.add(45);
        ids.stream().
                filter((i)->i < 4).
                map(i-> i * 2).forEach(System.out::println);
    }

    public static void throwException(){
        int i = 1;
        System.out.println("i="+i);

    }

    public static void main(String[] args) {
//        lineBreakPoint();
//        detailBreakPoint();
//        forceReturn();
//        exception();
//        field();
//        IUserService iUserService = new UserServiceImpl();
//        iUserService.getById(1);
//        condition();
//        multipleThread();
//        stream();
        throwException();
    }

}
